package com.djsearch.adapter;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.djsearch.R;
import com.djsearch.bean.WineShop;
import com.djsearch.data.ImageManager;
import com.djsearch.data.RequestImage;
/**
 * 酒店页面listview适配器
 * @author chenyang2
 *
 */
public class JiuDianListViewAdapter extends BaseAdapter {
	

	private Context mContext;
	private List<WineShop> wineShopList;
	private Bitmap mbitmap;
	public JiuDianListViewAdapter(Context context,List<WineShop> wineShopList) {
		mContext = context;
		this.wineShopList = wineShopList;
		Bitmap bitmap = ImageManager.drawableToBitmap(mContext.getResources().getDrawable(R.drawable.taogou),150.0f);
		mbitmap = (ImageManager.resizeImage(bitmap, 150.0f));
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return wineShopList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return wineShopList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (convertView == null) {
			LayoutInflater layoutInflater = ((Activity) mContext).getLayoutInflater();
			convertView = layoutInflater.inflate(R.layout.jiudian_listview_item, parent, false);
			convertView.setTag(convertView);
		} else {
			convertView = (View) convertView.getTag();
		}
		//酒店图片
		ImageView jiuDianImg = (ImageView)convertView.findViewById(R.id.jiuDianImg);
		RequestImage.getIntance(mbitmap, "JiuDian").download(wineShopList.get(position).
				getSmallImage(), jiuDianImg);
		//酒店名字
		TextView jiuDianName = (TextView)convertView.findViewById(R.id.jiuDianNameText);
		jiuDianName.setText(wineShopList.get(position).getHouseName());
		//酒店评分
		TextView jiuDianPingFen = (TextView)convertView.findViewById(R.id.pingFenText);
		jiuDianPingFen.setText(wineShopList.get(position).getHouseSorce());
		//酒店评分
		TextView jiuDianPrice = (TextView)convertView.findViewById(R.id.priceText);
		//酒店地址
		TextView jiuDianAddress = (TextView)convertView.findViewById(R.id.addressText);
		jiuDianAddress.setText(wineShopList.get(position).getHouseAddress());
		//“礼 ”标志
		TextView markOne = (TextView)convertView.findViewById(R.id.markOneText);
		//“返 ”标志
		TextView markTwo = (TextView)convertView.findViewById(R.id.markTwoText);
		
		return convertView;
	}





}
